import wx
import pyHook
import itunes

"""
Option 1:
  Figure out pyHook and get it working...

Option 2:
  
"""

class myFrame(wx.Frame):
  def __init__(self):
    wx.Frame.__init__(self, None, -1, 'My Frame')
    
    self.hm = pyHook.HookManager()
    self.hm.KeyDown = self.OnKeyboardEvent
  
    self.hm.HookKeyboard()
    
    wx.EVT_CLOSE(self, self.OnClose)
  
  def OnGetAO(self, event):
    if event.KeyID == 176:
        itunes.app.NextTrack()
    
  def OnKeyboardEvent(self, event):
    event.Type = 'keyboard'
    wx.CallAfter(self.OnGetAO, event)
    
  def OnClose(self, event):
    del self.hm
    itunes.close()
    self.Destroy()
  
if __name__ == '__main__':
  itunes.connect()
  
  app = wx.PySimpleApp(0)
  frame = myFrame()
  app.SetTopWindow(frame)
  frame.Show()  
  app.MainLoop()